
export default {
	state: {
		isCollapse: false,   // 用于控制菜单展开/收起
		tabsList: [
			{
				path: '/index',
				authName: '首页',
			}
		],   // 面包屑
		menuData: []
	},
	mutations: {
		clearState (state) {
			state.tabsList = [{
				path: 'index',
				authName: '首页',
			}];
			state.menuData = [];
		},
		// 更新面包屑数据
		selectMenu (state, value) {
			console.log(value);
			// 判断添加的数据是否为首页
			if (value.path !== 'index') {
				// 存在返回1
				const index = state.tabsList.findIndex(item => item.path === value.path)
				// 如果不存在 返回-1
				if (index === -1) {
					state.tabsList.push(value)
				}
			}
		},
		// 删除指定的tag数据
		closeTag(state, item) {
			console.log(item);
			const index = state.tabsList.findIndex(val => val.path === item.path)
			state.tabsList.splice(index, 1);
		}
	}
}
